package com.google.code.solrdimension.config.converters;

import java.util.List;

import com.google.code.solrdimension.config.dimensionvalue.AbstractDimensionValueConfig;
import com.google.code.solrdimension.parsers.beans.Dimension;
import com.google.code.solrdimension.parsers.beans.DimensionValue;

/**
 * The AbstractDimensionConfigConverter provides common operations necessary for converting an
 * {@link DimensionValueConfig} to {@link AbstractDimensionValueConfig}
 * 
 * @author mhc
 *
 */
public abstract class AbstractDimensionConfigConverter implements DimensionValueConverter {


    /**
     * Setting common fields in dimensionValueConfig inherited from AbstractDimensionValueConfig
     * 
     * @param dimensionValueConfig
     *            An instance of subclass of {@link AbstractDimensionValueConfig}
     * @param dimensionValue
     *            An instance of subclass of {@link DimensionValue}
     * @param dimension
     *            The dimension encapsulating the dimensionvalues
     */
    public void setCommonFields(AbstractDimensionValueConfig dimensionValueConfig, DimensionValue dimensionValue, Dimension dimension){
        
        if (dimensionValueConfig != null && dimensionValue != null && dimension != null){
            
            dimensionValueConfig.setDimensionId(dimension.getId());
            dimensionValueConfig.setDisplayName(dimensionValue.getName());
            dimensionValueConfig.setDimensionValueId(dimension.getId() + dimensionValue.getId());
            dimensionValueConfig.setOrder(dimensionValue.getOrder());
            
        } else {
            //TODO - consider throwing some sort of exception
        }
        
    }
}
